]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/keyboard: Handle IBus engines which don't specify a symbol
authorRui Matos <tiagomatos@gmail.com>
Sun, 9 Sep 2012 20:44:25 +0000 (22:44 +0200)
committerRui Matos <tiagomatos@gmail.com>
Wed, 12 Sep 2012 16:54:51 +0000 (18:54 +0200)
In this case, fall back to the 2 or 3 letter language code or, failing
that, to a keyboard symbol.

https://bugzilla.gnome.org/show_bug.cgi?id=683613

js/ui/status/keyboard.js

index 3dd7e3f5c79b2517015998534ba0f7de077b745b..ce5824e420b32db76d1b33c8cddd538e0c053dc4 100644 (file)
@@ -245,7 +245,7 @@ const InputSourceIndicator = new Lang.Class({
 
                     info.exists = true;
                     info.displayName = language + ' (' + engineDesc.get_longname() + ')';
-                    info.shortName = engineDesc.get_symbol();
+                    info.shortName = this._makeEngineShortName(engineDesc);
                 }
             }
 
@@ -320,6 +320,18 @@ const InputSourceIndicator = new Lang.Class({
         Util.spawn(['gkbd-keyboard-display', '-l', description]);
     },
 
+    _makeEngineShortName: function(engineDesc) {
+        let symbol = engineDesc.get_symbol();
+        if (symbol && symbol[0])
+            return symbol;
+
+        let langCode = engineDesc.get_language().split('_', 1)[0];
+        if (langCode.length == 2 || langCode.length == 3)
+            return langCode.toLowerCase();
+
+        return String.fromCharCode(0x2328); // keyboard glyph
+    },
+
     _containerGetPreferredWidth: function(container, for_height, alloc) {
         // Here, and in _containerGetPreferredHeight, we need to query
         // for the height of all children, but we ignore the results